<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>创建活动</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" href="../../../static/plugin/layui/css/layui.css" th:href="@{/plugin/layui/css/layui.css}"
          media="all"/>
    <link rel="stylesheet" href="../../../static/back_css/create_activity.css"
          th:href="@{/back_css/create_activity.css}" media="all">
</head>
<body>
<div th:if="${level}==4" style="margin: 350px 500px;width: 500px"><h3 style="color: red">您没有权限创建活动！如需创建活动请联系上级管理人员！</h3>
</div>
<div id="main" th:if="${level}!=4">
    <div class="content">
        <form class="layui-form content1" id="dept_info" action="" method="post">
            <div class="layui-form_bottom">
                <span>第一步：参与单位</span>
                <button type="button" id="btn1_cancel" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">
                    取消
                </button>
                <button type="button" id="btn_nextstep1" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">下一步
                </button>
            </div>
            <div class="layui-form_content">
                <div class="layui-form-item">
                    <label class="layui-form-label">活动单位</label>
                    <div class="layui-input-block">
                        <input type="radio" name="DEPT_TYPE" lay-filter="DEPT_TYPE" value="0" title="仅本级单位组织" checked>
                        <input type="radio" name="DEPT_TYPE" lay-filter="DEPT_TYPE" value="1" title="与下级单位联合组织">
                    </div>
                </div>
                <div id="deptTree" class="layui-form-item" style="display: none;">
                    <label class="layui-form-label">单位选择</label>
                    <div class="layui-input-block">
                        <div id="deptTree_div" class="ztree"></div>
                    </div>
                </div>
            </div>
        </form>

        <form class="layui-form content2" id="basic_info" action="" method="post">
            <div class="layui-form-bottom ">
                <span>第二步：活动信息</span>
                <button type="button" id="btn2_cancel" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">
                    取消
                </button>
                <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-reds" id="btn_prevstep2">
                    上一步
                </button>
                <button type="button" id="btn_nextstep2" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">
                    下一步
                </button>
            </div>
            <div class="layui-form_content">
                <div class="layui-form-item">
                    <label class="layui-form-label">活动标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="ACTIVITY_NAME" id="ACTIVITY_NAME" maxlength="60" lay-verify="title"
                            autocomplete="off" placeholder="请输入活动标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">活动主题</label>
                    <div class="layui-input-block">
                        <input type="text" name="ACTIVITY_TOPIC" id="ACTIVITY_TOPIC" lay-verify="title" 
                            autocomplete="off" placeholder="请输入活动主题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">活动封面</label>
                    <div class="layui-input-block jacket_btn">
                        <input name="ACTIVITY_IMG" class="upload_img" id="ACTIVITY_IMG" type="hidden">
                        <div class="upload_jacket_img"  >
                        </div>
                        <span class="prompt">请上传尺寸为750*360px的PNG、JPG、GIF图片，大小&lt;10M</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">活动形式</label>
                    <div class="layui-input-block">
                        <input type="radio" name="ACTIVITY_WAY" lay-filter="ACTIVITY_WAY" value="0" title="线上" checked>
                        <input type="radio" name="ACTIVITY_WAY" lay-filter="ACTIVITY_WAY" value="1" title="线下">
                        <input type="radio" name="ACTIVITY_WAY" lay-filter="ACTIVITY_WAY" value="2" title="线上+线下">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">主办单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="ZBDW" id="ZBDW" lay-verify="title" autocomplete="off"
                            placeholder="请输入主办单位" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">承办单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="CBDW" id="CBDW" lay-verify="title" autocomplete="off"
                            placeholder="请输入承办单位" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">执行承办</label>
                    <div class="layui-input-block">
                        <input type="text" name="ZXCB" id="ZXCB" lay-verify="title" autocomplete="off"
                            placeholder="请输入执行承办" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline" style="width: 800px;">
                        <label class="layui-form-label">活动时间</label>
                        <div class="layui-input-inline date_border">
                            <i class="layui-icon layui-icon-date"></i>
                            <input id="global_start_time" type="text" name="start_date" lay-verify="datetime" placeholder="设置开始时间"
                                autocomplete="off" class="layui-input date">
                        </div>
                        <div class="layui-input-inline date_border">
                            <i class="layui-icon layui-icon-date"></i>
                            <input id="global_end_time" type="text" name="end_date" lay-verify="datetime" placeholder="设置结束时间"
                                autocomplete="off" class="layui-input date">
                        </div>
                        <div class="layui-input-inline open_create">
                            <input type="checkbox" name="detail_time_open" lay-filter="detail_time_open" lay-skin="primary"
                                title="开启详细时间设置">
                        </div>
                    </div>
                    <div class="layui-inline add_time">
                        <button class="layui-btn" id="add_match_time_item">添加</button>
                        <span class="prompt">最多添加4个时间段</span>
                    </div>
                </div>
                <div id="match_date_list" style="width: 1000px;">
                </div>
            </div>
        </form>

        <form class="layui-form content3" id="detail_info" action="" method="post">
            <div class="layui-form-bottom ">
                <span>第三步：活动详情</span>
                <button type="button" id="btn3_cancel" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">
                    取消
                </button>
                <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-reds" id="btn_prevstep3">
                    上一步
                </button>
                <button type="button" id="btn_nextstep3" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">
                    下一步
                </button>
            </div>
            <div class="layui-form-content">
                <div class="layui-form-item">
                    <label class="layui-form-label">活动详情</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入活动简介" id="ACTIVITY_DETAILS" name="ACTIVITY_DETAILS"></textarea>
                    </div>
                </div>
            </div>
        </form>

        <form class="layui-form content4" id="time_prize_info" action="" method="post">
            <div class="layui-form-bottom ">
                <span>第四步：奖品规则</span>
                <button type="button" id="btn4_cancel" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">
                    取消
                </button>
                <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-reds" id="btn_prevstep4">
                    上一步
                </button>
                <button type="button" id="btn_nextstep4" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">
                    下一步
                </button>
            </div>
            <div class="layui-form-content">
                <div class="prize_item_list">
                    <div class="layui-inline">
                        <label class="layui-form-label">奖项设置</label>
                        <div class="layui-input-inline add_prize">
                            <button class="layui-btn" id="add_prize_item">添加</button>
                            <span class="prompt">最多添加3个</span>
                        </div>
                    </div>
                    <div id="prize_name_list">
                    </div>
                    <div class="layui-inline prize_rule">
                        <label class="layui-form-label">获奖规则</label>
                        <div class="layui-inline">
                            <textarea placeholder="请输入内容" id="PRIZE_RULE" maxlength="2000" name="rule" class="layui-textarea"
                                style="width: 773px;"></textarea>
                        </div>
                    </div>
                    <!-- <div class="layui-inline prize_rule">
                        <label class="layui-form-label" style="color: red;font-size: 21px">注意！</label>
                        <div class="layui-inline">
                            <h2 style="color: red">创建完成该活动后如需更改设置请到“活动详情”>>“活动设置”中设置具体事项！</h2>
                            <h4 style="color: red">该活动默认设置如下：</h4>
                            <h6 style="color: red">手机端是否显示：显示</h6>
                            <h6 style="color: red">投票设置：未开始</h6>
                            <h6 style="color: red">报名是否结束：未结束</h6>
                            <h6 style="color: red">该活动每人上传作品数：1</h6>
                            <h6 style="color: red">每天每人点赞次数：3</h6>
                            <h6 style="color: red">每天对同一作品点赞数：1</h6>
                            <h6 style="color: red">管理员是否提交作品 ：不提交</h6>
                            <h6 style="color: red">手机展示作品阶段：审核通过之前</h6>
                            <h6 style="color: red">上传作品类型：视频、音频、范文朗读</h6>
                            <h6 style="color: red">各地区提交作品数量：10</h6>
                            <h6 style="color: red">活动状态：进行中</h6>
                            <h6 style="color: red">手机端是否进入该活动：是</h6>
                            <h6 style="color: red">手机端是否显示获奖名单：不显示</h6>
                        </div>
                    </div> -->
                </div>
            </div>
        </form>

        <form class="layui-form content5" id="rule_info" action="" method="post">
            <div class="layui-form-bottom ">
                <span>第五步：活动设置</span>
                <button type="button" id="btn5_cancel" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">
                    取消
                </button>
                <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-reds" id="btn_prevstep5">
                    上一步
                </button>
                <button type="button" id="btn_nextstep5" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">
                    下一步
                </button>
            </div>
            <div class="layui-form-content" style="width: 1200px;">
                <div class="layui-form-item">
                    <label class="layui-form-label">阅读测评设置</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_OPEN_YDCP" value="1" title="开启" checked>
                        <input type="radio" name="IS_OPEN_YDCP" value="0" title="关闭">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">测评次数</label>
                    <div class="layui-input-inline">
                        <input type="number" id="YDCP_NUM" name="YDCP_NUM" lay-verify="title" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机端查看活动排名</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_SHOW" value="1" title="开启" checked>
                        <input type="radio" name="IS_SHOW" value="0" title="关闭">
                    </div>
                </div>
                <div class="layui-form-item">
                    <input type="hidden" id="ORDER_RULE" name="ORDER_RULE"/>
                    <label class="layui-form-label">活动排行规则</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="ORDER_JG" title="机构排行" value="1" lay-skin="primary">
                        <input type="checkbox" name="ORDER_DQ" title="地区排行" value="1" lay-skin="primary">
                        <input type="checkbox" name="ORDER_ZB" title="总榜排行" value="1" lay-skin="primary">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">分组归集规则</label>
                    <div class="layui-input-block" style="display: flex;">
                        <input type="radio" name="GROUP_RULE" lay-filter="GROUP_RULE" value="0" title="不开启" checked>
                        <input type="radio" name="GROUP_RULE" lay-filter="GROUP_RULE" value="1" title="开启">
                    </div>
                    <div class="layui-inline" id="ruleList" style="display: none;">
                        <input type="radio" name="GROUP_RULE_TYPE" lay-filter="GROUP_RULE_TYPE" value="1" title="按年龄分组" checked>
                        <input type="radio" name="GROUP_RULE_TYPE" lay-filter="GROUP_RULE_TYPE" value="2" title="按阅读等级分组">
                        <button class="layui-btn" id="add_group_rule_item">添加</button>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">年龄类型</label>
                    <div class="layui-input-block">
                        <input type="radio" name="AGE_TYPE" lay-filter="AGE_TYPE" value="0" title="入学年龄" checked>
                        <input type="radio" name="AGE_TYPE" lay-filter="AGE_TYPE" value="1" title="周岁年龄">
                    </div>
                </div>
                <div class="layui-form-item" id="ageInfo">
                    <label class="layui-form-label">年龄范围</label>
                    <div class="layui-input-inline" style="display: flex; align-items: center; gap: 5px;">
                        <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MIN_AGE" id="MIN_AGE"
                            style="width: 50px;">
                        <span>岁</span>
                        <span>----</span>
                        <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MAX_AGE" id="MAX_AGE"
                            style="width: 50px;">
                        <span>岁</span>
                    </div>
                </div>

                <div id="group_rule_list" style="width: 1000px;">
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">该活动是否设置投票</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_ROTE" value="1" title="不设置" checked>
                        <input type="radio" name="IS_ROTE" value="0" title="设置">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">投票阶段设置</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_VOTE" value="0" title="未开始" checked>
                        <input type="radio" name="IS_VOTE" value="1" title="开启投票">
                        <input type="radio" name="IS_VOTE" value="2" title="投票结束">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" style="width: 800px;">
                        <label class="layui-form-label">报名截止时间</label>
                        <div class="layui-input-inline date_border">
                            <i class="layui-icon layui-icon-date"></i>
                            <input id="ACTIVITY_ENTRYTIME" type="text" name="ACTIVITY_ENTRYTIME" lay-verify="datetime" placeholder="设置报名截止时间"
                                autocomplete="off" class="layui-input date">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">报名设置</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_SIGUP" value="0" title="正在进行报名" checked>
                        <input type="radio" name="IS_SIGUP" value="1" title="结束报名">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">限定每人上传作品数</label>
                    <div class="layui-input-inline">
                        <input type="number" id="WORKS_LIMIT_PERUSER" name="WORKS_LIMIT_PERUSER" lay-verify="title" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">每天限制点赞次数</label>
                    <div class="layui-input-inline">
                        <input type="number" id="VOTES_LIMIT_PERDAY" name="VOTES_LIMIT_PERDAY" lay-verify="title" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">每天对同一作品点赞次数</label>
                    <div class="layui-input-inline">
                        <input type="number" id="VOTES_LIMIT_TOSINGLE_PERDAY" name="VOTES_LIMIT_TOSINGLE_PERDAY" lay-verify="title" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">管理员是否提交作品</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_SUBMIT" value="0" title="不提交">
                        <input type="radio" name="IS_SUBMIT" value="1" title="提交" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机端展示作品阶段</label>
                    <div class="layui-input-block">
                        <input type="radio" name="CURRENT_STAGE" value="0" title="审核通过阶段（审核通过之前）" checked>
                        <input type="radio" name="CURRENT_STAGE" value="1" title="提交阶段（各级管理员提交的作品）"><br>
                        <input type="radio" name="CURRENT_STAGE" value="2" title="晋级作品（活动发布者晋级的作品）">
                    </div>
                </div>
                <div class="layui-form-item">
                    <input type="hidden" id="WORK_TYPE" name="WORK_TYPE"/>
                    <label class="layui-form-label">作品类型</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="V_TYPE" title="视频作品" value="1" lay-skin="primary">
                        <input type="checkbox" name="A_TYPE" title="音频作品" value="1" lay-skin="primary">
                        <input type="checkbox" name="F_TYPE" title="范文朗读" value="1" lay-skin="primary">
                        <input type="checkbox" name="P_TYPE" title="图片作品" value="1" lay-skin="primary">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">各地区提交作品数量</label>
                    <div class="layui-input-inline">
                        <input type="number"id="SUBMIT_WORK_NUMBER" name="SUBMIT_WORK_NUMBER" lay-verify="title" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机端是否显示</label>
                    <div class="layui-input-block">
                        <input type="radio" name="DELETED" value="0" title="显示" checked>
                        <input type="radio" name="DELETED" value="1" title="不显示">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">活动状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="ACTIVITY_STATE" value="0" title="未开始" checked>
                        <input type="radio" name="ACTIVITY_STATE" value="1" title="进行中">
                        <input type="radio" name="ACTIVITY_STATE" value="2" title="已结束">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机端是否进入该活动</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_IN" value="1" title="是" checked>
                        <input type="radio" name="IS_IN" value="0" title="否">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机端是否显示获奖名单</label>
                    <div class="layui-input-block">
                        <input type="radio" name="WINNERS" value="0" title="不显示">
                        <input type="radio" name="WINNERS" value="1" title="显示" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否显示评论</label>
                    <div class="layui-input-block">
                        <input type="radio" name="IS_SHOW_COMMENT" value="1" title="是" checked>
                        <input type="radio" name="IS_SHOW_COMMENT" value="0" title="否">
                    </div>
                </div>
            </div>
        </form>

        <form class="layui-form content6" id="result_info" action="" method="post">
            <div class="layui-form-bottom ">
                <span>第六步：活动发布</span>
                <button type="button" id="btn6_cancel" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">
                    取消
                </button>
                <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-reds" id="btn_prevstep6">
                    上一步
                </button>
                <button type="button" lay-filter="sign" lay-submit
                    class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">确定
                </button>
            </div>
            <div class="layui-form-content" style="width: 1000px;">
                <div class="layui-form-item">
                    <label class="layui-form-label">加入活动模板</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="IS_TEMPLATE" title="同意本活动加入《活动模板》公开引用" value="1" lay-skin="primary">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline prize_rule">
                        <div class="layui-inline">
                            <h2 style="color: red">温馨提示：已经发布的活动，可在活动管理相关操作中进行编辑修改</h2>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<datalist class="race_stage" id="match_name_list" name="matchset">
    <option value="初赛"></option>
    <option value="复赛"></option>
    <option value="决赛"></option>
</datalist>
<datalist class="race_stage" id="match_way_list" name="matchway">
    <option value="线上"></option>
    <option value="线下"></option>
    <option value="线上+线下"></option>
</datalist>
<script type="text/html" id="match_date_item">
    <form class="layui-form-item match">
        <div class="match_name">
            <input class="layui-input" type="text" name="STAGE_NAME" list="match_name_list" placeholder="名称">
        </div>
        <div class="match_name">
            <input class="layui-input" type="text" name="STAGE_WAY" list="match_way_list" placeholder="方式">
        </div>
        <div class="layui-inline">
            <label class="layui-form-label time_set">时间设置</label>
            <div class="layui-input-inline date_border">
                <i class="layui-icon layui-icon-date"></i>
                <input type="text" name="match_start_date" lay-verify="datetime" placeholder="2025-04-01"
                       autocomplete="off"
                       class="layui-input date">
            </div>
            <label class="layui-form-label date_set1">至</label>
            <div class="layui-input-inline date_border">
                <i class="layui-icon layui-icon-date"></i>
                <input type="text" name="match_end_date" lay-verify="datetime" placeholder="2025-04-01"
                       autocomplete="off"
                       class="layui-input date ">
            </div>
        </div>
        <button type="button" class="layui-btn matchtime_del">删除</button>
    </form>
</script>
<script type="text/html" id="prize_name_item">
    <form class="layui-form-item prize_item">
        <div class="layui-inline">
            <label class="layui-form-label time_set">奖项名称</label>
            <div class="layui-input-inline date_border">
                <input type="text" autocomplete="off" class="layui-input" list="3" placeholder="奖项名称" name="PRIZE_NAME">
                <datalist class="race_stage" id="3">
                    <option th:each="prize:${prizes}" th:value="${prize}"></option>
                </datalist>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label people_num">人数</label>
            <div class="layui-input-inline date_border">
                <input type="number" autocomplete="off" value="1" min="1" class="layui-input" name="PRIZE_USERNUMBER">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label people_num">奖品</label>
            <div class="layui-input-inline date_border">
                <input type="text" autocomplete="off"  placeholder="奖品名称" class="layui-input" name="PRIZE_GOODS">
            </div>
        </div>
        <button class="layui-btn prizename_del">删除</button>
        <div class="layui-form-item">
            <label class="layui-form-label time_set">奖品封面</label>
            <div class="layui-input-block jacket_btn1">
                <input type="hidden" class="upload_img"  name="PRIZE_GOODS_IMG">
                <div class="upload_jacket_img1">
                </div>
                <span class="prompt">请上传尺寸为750*360px的PNG、JPG、GIF图片，大小不超过10M</span>
            </div>
        </div>
    </form>
</script>

<script type="text/html" id="group_rule_item">
    <form class="layui-form-item rule_item" style="width: 1000px;">
        <div class="layui-inline">
            <label class="layui-form-label">分组名称</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" placeholder="分组名称" name="GROUP_NAME" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">请输入年龄范围</label>
            <div class="layui-input-inline" style="display: flex; align-items: center; gap: 5px;">
                <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MIN" style="width: 50px;">
                <span>岁</span>
                <span>----</span>
                <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MAX" style="width: 50px;">
                <span>岁</span>
            </div>
        </div>
        <button class="layui-btn rule_del" style="background-color: crimson;">删除</button>
    </form>
</script>

<script type="text/html" id="group_rule_item_level">
    <form class="layui-form-item rule_item_level" style="width: 1000px;">
        <div class="layui-inline">
            <label class="layui-form-label">分组名称</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" placeholder="分组名称" name="GROUP_NAME" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">请输入阅读等级范围</label>
            <div class="layui-input-inline" style="display: flex; align-items: center; gap: 5px;">
                <span>L</span>
                <input type="number" autocomplete="off" value="0" min="0" max="12" class="layui-input" name="MIN" style="width: 50px;">
                <span>----</span>
                <span>L</span>
                <input type="number" autocomplete="off" value="0" min="0" max="12" class="layui-input" name="MAX" style="width: 50px;">
            </div>
        </div>
        <button class="layui-btn rule_del_level" style="background-color: crimson;">删除</button>
    </form>
</script>

<script type="text/javascript" src="../../../static/plugin/layui/layui.js" th:src="@{/plugin/layui/layui.js}"></script>
<script type="text/javascript">
    var curStep = 1;//当前步骤
    var laydate;
    var $;
    layui.use(['form', "laydate", "jquery", "element", 'layer', "layedit", "tree"], function () {
        var form = layui.form,
            layer = layui.layer;
        var element = layui.element;
        var layedit = layui.layedit;
        var tree = layui.tree;
        $ = layui.jquery;
        laydate = layui.laydate;
        htmlss = layedit.build('ACTIVITY_DETAILS', {//建立编辑器
            tool: ['strong' //加粗
                , 'italic' //斜体
                , 'underline' //下划线
                , 'del' //删除线
                , 'left' //左对齐
                , 'center' //居中对齐
                , 'right' //右对齐
                , 'link' //超链接
                , 'unlink' //清除链接
                , 'face'
            ]
        });
        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        }
        function initDeptTree() {
            $.ajax({
                url: '/district/tree',
                type: 'POST',
                success: function (data) {
                    const treeData = convertToTree(data);
                    console.log("组织树：",treeData);
                    tree.render({
                        id: 'deptTree',
                        elem: '#deptTree_div',
                        data: treeData,
                        showCheckbox: true
                    });
                },
                error: function (reason) {
                    layer.msg("网络错误！")
                }
            })
        }
        function convertToTree(data) {
            data.forEach(item => {
                item.title = item.district_NAME; // 显式设置 title 字段
            });
            var map = {};
            data.forEach(item => {
                map[item.id] = item;
            });
            var roots = [];
            data.forEach(item => {
                if (item.parent_ID === 1) {
                    roots.push(item);
                } else {
                    const parent = map[item.parent_ID];
                    if (!parent.children){
                        parent.children = [];
                    }
                    parent.children.push(item);
                }
            });
            return roots;
        }

        function getCheckedId(data) {
            var id = "";
            $.each(data, function (index, item) {
                if (id != "") {
                    id = id + "," + item.id;
                }else {
                    id = item.id;
                }
                if (item.children != null) {
                    var i = getCheckedId(item.children);
                    if (i != "") {
                        id = id + "," + i;
                    }
                }
            });
            return id;
        }
        function getCheckedName(data) {
            var name = "";
            $.each(data, function (index, item) {
                if (name != "") {
                    name = name + "," + item.title;
                } else {
                    name = item.title;
                }
                if (item.children != null) {
                    var i = getCheckedName(item.children);
                    if (i != "") {
                        name = name + "," + i;
                    }
                }
            });
            return name;
        }

        function nextStep() {
            var dept = $("#dept").val();
            if (curStep == 1) {
                $(".content1").animate({ left: '-1000px' });
                $(".content2").animate({ left: '0' });
                $(".content3").animate({ left: '1000px' });
                $(".content4").animate({ left: '2000px' });
                $(".content5").animate({ left: '3000px' });
                $(".content6").animate({ left: '4000px' });
            } else if (curStep == 2) {
                var ACTIVITY_NAME = $("#ACTIVITY_NAME").val();
                if (ACTIVITY_NAME == ''|| ACTIVITY_NAME == null|| ACTIVITY_NAME == undefined) {
                    layer.msg("活动标题不能为空！");
                    return;
                }
                var ACTIVITY_IMG = $("#ACTIVITY_IMG").val();
                if (ACTIVITY_IMG == '' || ACTIVITY_IMG == null || ACTIVITY_IMG == undefined) {
                    layer.msg("活动封面不能为空！");
                    return;
                }
                var ZBDW = $("#ZBDW").val();
                if (ZBDW == '' || ZBDW == null || ZBDW == undefined) {
                    layer.msg("主办单位不能为空！");
                    return;
                }
                $(".content1").animate({ left: '-2000px' });
                $(".content2").animate({ left: '-1000px' });
                $(".content3").animate({ left: '0' });
                $(".content4").animate({ left: '1000px' });
                $(".content5").animate({ left: '2000px' });
                $(".content6").animate({ left: '3000px' });
            } else if (curStep == 3) {
                var ACTIVITY_DETAILS = layedit.getContent(htmlss);
                if (ACTIVITY_DETAILS == '' || ACTIVITY_DETAILS == null || ACTIVITY_DETAILS == undefined) {
                    layer.msg("活动详情不能为空！");
                    return;
                }
                $(".content1").animate({ left: '-3000px' });
                $(".content2").animate({ left: '-2000px' });
                $(".content3").animate({ left: '-1000px' });
                $(".content4").animate({ left: '0' });
                $(".content5").animate({ left: '1000px' });
                $(".content6").animate({ left: '2000px' });
            } else if (curStep == 4) {
                $(".content1").animate({ left: '-4000px' });
                $(".content2").animate({ left: '-3000px' });
                $(".content3").animate({ left: '-2000px' });
                $(".content4").animate({ left: '-1000px' });
                $(".content5").animate({ left: '0' });
                $(".content6").animate({ left: '1000px' });
            } else if (curStep == 5) {
                $(".content1").animate({ left: '-5000px' });
                $(".content2").animate({ left: '-4000px' });
                $(".content3").animate({ left: '-3000px' });
                $(".content4").animate({ left: '-2000px' });
                $(".content5").animate({ left: '-1000px' });
                $(".content6").animate({ left: '0' });
            }
            curStep++;
        }
        function prevStep() {
            if (curStep == 2) {
                $(".content1").animate({ left: '0' });
                $(".content2").animate({ left: '1000px' });
                $(".content3").animate({ left: '2000px' });
                $(".content4").animate({ left: '3000px' });
                $(".content5").animate({ left: '4000px' });
                $(".content6").animate({ left: '5000px' });
            } else if (curStep == 3) {
                $(".content1").animate({ left: '-1000px' });
                $(".content2").animate({ left: '0' });
                $(".content3").animate({ left: '1000px' });
                $(".content4").animate({ left: '2000px' });
                $(".content5").animate({ left: '3000px' });
                $(".content6").animate({ left: '4000px' });
            } else if (curStep == 4) {
                $(".content1").animate({ left: '-2000px' });
                $(".content2").animate({ left: '-1000px' });
                $(".content3").animate({ left: '0' });
                $(".content4").animate({ left: '1000px' });
                $(".content5").animate({ left: '2000px' });
                $(".content6").animate({ left: '3000px' });
            } else if (curStep == 5) {
                $(".content1").animate({ left: '-3000px' });
                $(".content2").animate({ left: '-2000px' });
                $(".content3").animate({ left: '-1000px' });
                $(".content4").animate({ left: '0' });
                $(".content5").animate({ left: '1000px' });
                $(".content6").animate({ left: '2000px' });
            } else if (curStep == 6) {
                $(".content1").animate({ left: '-4000px' });
                $(".content2").animate({ left: '-3000px' });
                $(".content3").animate({ left: '-2000px' });
                $(".content4").animate({ left: '-1000px' });
                $(".content5").animate({ left: '0' });
                $(".content6").animate({ left: '1000px' });
            }
            curStep--;
        }
        
        $("#btn_nextstep1").click(function () {
            nextStep();
        });
        $("#btn_nextstep2").click(function () {
            nextStep();
        });
        $("#btn_nextstep3").click(function () {
            nextStep();
        });
        $("#btn_nextstep4").click(function () {
            nextStep();
        });
        $("#btn_nextstep5").click(function () {
            nextStep();
        });

        $("#btn_prevstep2").click(function () {
            prevStep();
        });
        $("#btn_prevstep3").click(function () {
            prevStep();
        });
        $("#btn_prevstep4").click(function () {
            prevStep();
        });
        $("#btn_prevstep5").click(function () {
            prevStep();
        });
        $("#btn_prevstep6").click(function () {
            prevStep();
        });


        $(".upload_jacket_img").on("click", function (a, b) {
            var that=this;
            // $(this).next(".upload_jacket_img1>span").hide();
            var ipt = document.createElement("input")
            ipt.type = "file";
            ipt.multiple = false;
            ipt.accept="image/*"
            ipt.onchange = function (ev) {
                console.log(ipt.files);
                if (ipt.files.length > 0) {
                    var formdata = new FormData();
                    formdata.append("file", ipt.files[0]);
                    formdata.append("dir","activity");
                    $.ajax({
                        url: "/operate/uploadImg",
                        data: formdata,
                        type: "post",
                        async: false,
                        processData: false,
                        contentType: false,
                        success: function (result) {
                            console.log("result:", result);
                            var path = result;
                            $(that).css("content", "url(" + path + ")");
                            $(that).siblings("input.upload_img").val(path);
                        },
                        error: function (ret) {
                            layer.msg("网络错误！")
                        }
                    })
                }
                ipt = null;
            }
            ipt.click();
        });
        laydate.render({
            elem: $("#global_start_time")[0],
            type: 'datetime',
            done: function (a, b, c) {
            }
        });

        laydate.render({
            elem: $("#global_end_time")[0],
            type: 'datetime',
            done: function (a, b, c) {
            }
        });

        laydate.render({
            elem: $("#ACTIVITY_ENTRYTIME")[0],
            type: 'datetime',
            done: function (a, b, c) {
            }
        });

        form.on("submit(sign)", function (data) {
            var ACTIVITY_NAME = $("#ACTIVITY_NAME").val();//活动名称
            var ACTIVITY_TOPIC = $("#ACTIVITY_TOPIC").val();//活动主题
            var html = layedit.getContent(htmlss);
            var ACTIVITY_STARTTIME = $("#global_start_time").val();//开始时间
            var ACTIVITY_ENDTIME = $("#global_end_time").val();//开始时间
            var PRIZE_RULE = $("#PRIZE_RULE").val();//获奖规则
            var ACTIVITY_WAY = $('input[name="ACTIVITY_WAY"]:checked').val();//活动形式

            var obj={};
            obj["ACTIVITY_IMG"]=$('#ACTIVITY_IMG').val();
            obj["ACTIVITY_NAME"]=ACTIVITY_NAME;
            obj["ACTIVITY_TOPIC"] = ACTIVITY_TOPIC;
            obj["ACTIVITY_DETAILS"]= html;
            obj["STARTTIME"]= ACTIVITY_STARTTIME;
            obj["ENDTIME"]= ACTIVITY_ENDTIME;
            obj["PRIZE_RULE"]= PRIZE_RULE;
            obj["ACTIVITY_WAY"] = ACTIVITY_WAY;
            obj["ZBDW"]= $("#ZBDW").val();
            obj["CBDW"]= $("#CBDW").val();
            obj["ZXCB"]= $("#ZXCB").val();

            var time_info = [];
            $("#match_date_list").children("form").each(function (index, item) {
                time_info.push($(item).serializeObject())
            });
            if (time_info.length != 0) {
                obj["STAGE_IS_OPEN"]=  1;
                obj["STAGE_1ST_NAME"]=  time_info[0].STAGE_NAME;
                obj["STAGE_1ST_WAY"] = time_info[0].STAGE_WAY;
                obj["ST1_STARTTIME"]=  time_info[0].match_start_date;
                obj["ST1_ENDTIME"]=  time_info[0].match_end_date;
                obj["STAGE_1ST_WIN"]=  0;
                if (time_info[1] != null) {
                    obj["STAGE_2ND_NAME"]= time_info[1].STAGE_NAME;
                    obj["STAGE_2ND_WAY"]= time_info[1].STAGE_WAY;
                    obj["ST2_STARTTIME"]= time_info[1].match_start_date;
                    obj["ST2_ENDTIME"]= time_info[1].match_end_date;
                    obj["STAGE_2ND_WIN"]= 0;
                }
                if (time_info[2] != null) {
                    obj["STAGE_3RD_NAME"]= time_info[2].STAGE_NAME;
                    obj["STAGE_3RD_WAY"]= time_info[2].STAGE_WAY;
                    obj["ST3_STARTTIME"]= time_info[2].match_start_date;
                    obj["ST3_ENDTIME"]= time_info[2].match_end_date;
                    obj["STAGE_3RD_WIN"]= 0;
                }
                if (time_info[3] != null) {
                    obj["STAGE_4TH_NAME"]= time_info[3].STAGE_NAME;
                    obj["STAGE_4TH_WAY"]= time_info[3].STAGE_WAY;
                    obj["ST4_STARTTIME"]= time_info[3].match_start_date;
                    obj["ST4_ENDTIME"]= time_info[3].match_end_date;
                    obj["STAGE_4TH_WIN"]= 0;
                }
            } else {
                obj["STAGE_IS_OPEN"]= 0;
            }

            var prize_info = [];
            $("#prize_name_list").children("form").each(function (index, item) {
                var tmp = $(item).serializeObject();
                prize_info.push(tmp)
            });
            obj.prizeInfos = prize_info;

            var deptType = $('input[name="DEPT_TYPE"]:checked').val();
            obj["DEPT_TYPE"] = deptType;
            if(tree.index==0){
                obj["DEPT_IDS"] = "";
                obj["DEPT_NAMES"] = "";
            }else{
                var checkedNodes = tree.getChecked('deptTree');
                var nodeIds = getCheckedId(checkedNodes);
                var nodeNames = getCheckedName(checkedNodes);
                obj["DEPT_IDS"] = nodeIds;
                obj["DEPT_NAMES"] = nodeNames;
            }
            obj["IS_OPEN_YDCP"] = $('input[name="IS_OPEN_YDCP"]:checked').val();
            obj["YDCP_NUM"] = $("#YDCP_NUM").val();
            obj["IS_SHOW"] = $('input[name="IS_SHOW"]:checked').val();
            obj["IS_SHOW_COMMENT"] = $('input[name="IS_SHOW_COMMENT"]:checked').val();
            obj["AGE_TYPE"] = $('input[name="AGE_TYPE"]:checked').val();
            obj["MIN_AGE"] = $("#MIN_AGE").val();
            obj["MAX_AGE"] = $("#MAX_AGE").val();

            var ORDER_JG = $('input[name="ORDER_JG"]:checked').val();
            if (undefined == ORDER_JG) {
                ORDER_JG = 0;
            }
            var ORDER_DQ = $('input[name="ORDER_DQ"]:checked').val();
            if (undefined == ORDER_DQ) {
                ORDER_DQ = 0;
            }
            var ORDER_ZB = $('input[name="ORDER_ZB"]:checked').val();
            if (undefined == ORDER_ZB) {
                ORDER_ZB = 0;
            }
            var order_rule = 0;
            if (ORDER_JG == 1 && ORDER_DQ == 0 && ORDER_ZB == 0) {//机构
                order_rule = 1
            } else if (ORDER_JG == 0 && ORDER_DQ == 1 && ORDER_ZB == 0) {//地区
                order_rule = 2;
            } else if (ORDER_JG == 0 && ORDER_DQ == 0 && ORDER_ZB == 1) {//总榜
                order_rule = 3;
            } else if (ORDER_JG == 1 && ORDER_DQ == 1 && ORDER_ZB == 0) {//机构、地区
                order_rule = 4;
            } else if (ORDER_JG == 1 && ORDER_DQ == 0 && ORDER_ZB == 1) {//机构、总榜
                order_rule = 5;
            } else if (ORDER_JG == 0 && ORDER_DQ == 1 && ORDER_ZB == 1) {//地区、总榜
                order_rule = 6;
            }else if (ORDER_JG == 1 && ORDER_DQ == 1 && ORDER_ZB == 1) {//机构、地区、总榜
                order_rule = 7;
            }
            obj["ORDER_RULE"] = order_rule;
            obj["GROUP_RULE"] = $('input[name="GROUP_RULE"]:checked').val();
            obj["GROUP_RULE_TYPE"] = $('input[name="GROUP_RULE_TYPE"]:checked').val();
            var group_rule_info = [];
            $("#group_rule_list").children("form").each(function (index, item) {
                var tmp = $(item).serializeObject();
                group_rule_info.push(tmp);
            });
            obj.groupRuleInfos = group_rule_info;

            obj["IS_VOTE"] = $('input[name="IS_VOTE"]:checked').val();
            obj["ENTRYTIME"] = $("#ACTIVITY_ENTRYTIME").val();
            obj["IS_SIGUP"] = $('input[name="IS_SIGUP"]:checked').val();
            obj["WORKS_LIMIT_PERUSER"] = $("#WORKS_LIMIT_PERUSER").val();
            obj["VOTES_LIMIT_PERDAY"] = $("#VOTES_LIMIT_PERDAY").val();
            obj["VOTES_LIMIT_TOSINGLE_PERDAY"] = $("#VOTES_LIMIT_TOSINGLE_PERDAY").val();
            obj["IS_SUBMIT"] = $('input[name="IS_SUBMIT"]:checked').val();
            obj["CURRENT_STAGE"] = $('input[name="CURRENT_STAGE"]:checked').val();

            var V_TYPE = $('input[name="V_TYPE"]:checked').val();
            if (undefined == V_TYPE) {
                V_TYPE = 0;
            }
            var A_TYPE = $('input[name="A_TYPE"]:checked').val();
            if (undefined == A_TYPE) {
                A_TYPE = 0;
            }
            var F_TYPE = $('input[name="F_TYPE"]:checked').val();
            if (undefined == F_TYPE) {
                F_TYPE = 0;
            }
            var P_TYPE = $('input[name="P_TYPE"]:checked').val();
            if (undefined == P_TYPE) {
                P_TYPE = 0;
            }
            var work_type = 0;
            if (V_TYPE == 1 && A_TYPE == 0 && F_TYPE == 0 && P_TYPE == 0) {// 视频
                work_type = 1
            } else if (V_TYPE == 0 && A_TYPE == 1 && F_TYPE == 0 && P_TYPE == 0) {// 音频
                work_type = 2;
            } else if (V_TYPE == 1 && A_TYPE == 1 && F_TYPE == 0 && P_TYPE == 0) {// 视频 音频
                work_type = 3;
            } else if (V_TYPE == 0 && A_TYPE == 0 && F_TYPE == 1 && P_TYPE == 0) {// 范文
                work_type = 4;
            } else if (V_TYPE == 1 && A_TYPE == 0 && F_TYPE == 1 && P_TYPE == 0) {// 视频 范文
                work_type = 5;
            } else if (V_TYPE == 0 && A_TYPE == 1 && F_TYPE == 1 && P_TYPE == 0) {// 音频 范文
                work_type = 6;
            } else if (V_TYPE == 1 && A_TYPE == 1 && F_TYPE == 1 && P_TYPE == 0) {// 视频 音频 范文
                work_type = 7;
            } else if (V_TYPE == 0 && A_TYPE == 0 && F_TYPE == 0 && P_TYPE == 1) {// 图片
                work_type = 8;
            } else if (V_TYPE == 1 && A_TYPE == 0 && F_TYPE == 0 && P_TYPE == 1) {// 视频 图片
                work_type = 9;
            } else if (V_TYPE == 0 && A_TYPE == 1 && F_TYPE == 0 && P_TYPE == 1) {// 音频 图片
                work_type = 10;
            } else if (V_TYPE == 1 && A_TYPE == 1 && F_TYPE == 0 && P_TYPE == 1) {// 视频 音频 图片
                work_type = 11;
            } else if (V_TYPE == 0 && A_TYPE == 0 && F_TYPE == 1 && P_TYPE == 1) {// 范文 图片
                work_type = 12;
            } else if (V_TYPE == 1 && A_TYPE == 0 && F_TYPE == 1 && P_TYPE == 1) {// 视频 范文 图片
                work_type = 13;
            } else if (V_TYPE == 0 && A_TYPE == 1 && F_TYPE == 1 && P_TYPE == 1) {// 音频 范文 图片
                work_type = 14;
            } else if (V_TYPE == 1 && A_TYPE == 1 && F_TYPE == 1 && P_TYPE == 1) {// 视频 音频 范文 图片
                work_type = 15;
            }
            obj["WORK_TYPE"] = work_type;
            
            obj["SUBMIT_WORK_NUMBER"] = $("#SUBMIT_WORK_NUMBER").val();
            obj["DELETED"] = $('input[name="DELETED"]:checked').val();
            obj["ACTIVITY_STATE"] = $('input[name="ACTIVITY_STATE"]:checked').val();
            obj["IS_IN"] = $('input[name="IS_IN"]:checked').val();
            obj["WINNERS"] = $('input[name="WINNERS"]:checked').val();
            obj["IS_ROTE"] = $('input[name="IS_ROTE"]:checked').val();
            var IS_TEMPLATE = $('input[name="IS_TEMPLATE"]:checked').val();
            if (undefined == IS_TEMPLATE) {
                IS_TEMPLATE = "0"
            }
            obj["IS_TEMPLATE"] = IS_TEMPLATE;
            obj["ACTIVITY_TYPE"] = "0";
            console.log("obj:", obj);
            layer.load(1);
            $.ajax({
                url: '/addActivity',
                type: 'POST',
                data: JSON.stringify(obj),
                contentType: "application/json",
                success: function (result) {
                    window.location.href = '/getAllActivity';
                },
                error:function(reason){
                    layer.msg("网络错误！")
                }
            })
            return false;
        })
        form.on("select()", function (obj) {

        });
        form.on("radio(DEPT_TYPE)", function (data) {
            if (data.value == "0") {
                $("#deptTree").css("display", "none");
            } else {
                $("#deptTree").css("display", "inline-block");
            }
            initDeptTree();
        });

        form.on("radio(GROUP_RULE)", function (data) {
            if (data.value == "0") {
                $("#ageInfo").css("display", "flex");
                $("#ruleList").css("display", "none");
                $("#group_rule_list").css("display", "none");
            } else {
                $("#ageInfo").css("display", "none");
                $("#ruleList").css("display", "inline-block");
                $("#group_rule_list").css("display", "inline-block");
            }
        });
        form.on("radio(GROUP_RULE_TYPE)", function (data) {
            $("#group_rule_list").empty();
        });

        form.on("checkbox(detail_time_open)", function (obj) {
            //获取表单元素 对应的渲染元素
            //  $(obj.elem).next().css_bak("background","green");
            //console.log(obj);
            if (obj.elem.checked) {
                if ($("#global_start_time").val() == "" || $("#global_end_time").val() == "") {
                    layer.msg("请先设置开始和结束时间")
                    obj.elem.checked = false;
                    obj.othis.removeClass("layui-form-checked");
                    return;
                }
                $(".add_time").css("display", "inline-block");
            } else {
                $(".add_time").css("display", "none");
                $("#match_date_list").empty();
            }
        })

        $("#match_date_list").on("click", ".matchtime_del", function (e) {
            if ($(this).parent().next().length <= 0) {
                //无前无后
                if ($(this).parent().prev().length <= 0) {
                    //直接删
                } else {//有前无后
                }
            } else {
                //有后无前
                if ($(this).parent().prev().length <= 0) {
                    $(this).parent().next().find(".date").first().prop("disabled", true);
                } else {//有前有后
                }
            }
            $(this).parent(".match").remove();
            return false;
        });
        $("#add_match_time_item").click(function (event) {//添加时间
            var s = $("#match_date_list").children().length;
            if (s < 4) {
                //设置第一项
                $("#match_date_list").append($("#match_date_item").html());
                s++;
                //使时间指示器生效
                $("#match_date_list").children().last().find(".date").each(function (index, item) {
                    laydate.render({
                        elem: item,
                        type: 'datetime',
                        //点击日期、清空、现在、确定均会触发。回调返回三个参数，分别代表：生成的值、日期时间对象、结束的日期时间对象
                        done: function (value, date, endDate) {
                        }
                    });
                })
                //添加时期同步更新
            } else {
                layer.msg("最多支持添加4个时间段！")
            }
            return false;
        });
        $("#prize_name_list").on("click",".prizename_del",function(){
            if ($(this).parent(".prize_item")) {
                $(this).parent(".prize_item").remove();
            }
            return false;
        })
        $("#prize_name_list").on("click",".upload_jacket_img1",function(){
            var that=this;
            // $(this).next(".upload_jacket_img1>span").hide();
            var ipt = document.createElement("input")
            ipt.type = "file";
            ipt.multiple = false;
            ipt.accept="image/*"
            ipt.onchange = function (ev) {
                console.log(ipt.files);

                if (ipt.files.length > 0) {
                    var formdata = new FormData();
                    formdata.append("file", ipt.files[0]);
                    formdata.append("dir","prize");
                    $.ajax({
                        url: "/operate/uploadImg",
                        data: formdata,
                        type: "post",
                        async: false,
                        processData: false,
                        contentType: false,
                        success: function (result) {
                            console.log("result:", result);
                            var path = result;
                            $(that).css("content", "url(" + path + ")");
                            $(that).siblings("input.upload_img").val(path);
                        },
                        error: function (ret) {
                            layer.msg("网络错误！")
                        }
                    })
                }
                ipt = null;
            }
            ipt.click();
            return false;
        })
        $("#add_prize_item").click(function (event) {//添加奖项
            $("#prize_name_list").append($("#prize_name_item").html());
            return false;
        });
        $("#add_group_rule_item").click(function (event) {//添加奖项
            var groupRuleType = $('input[name="GROUP_RULE_TYPE"]:checked').val();
            if(groupRuleType=="1"){
                $("#group_rule_list").append($("#group_rule_item").html());
            }else{
                $("#group_rule_list").append($("#group_rule_item_level").html());
            }
            return false;
        });
        $("#group_rule_list").on("click", ".rule_del", function () {
            if ($(this).parent(".rule_item")) {
                $(this).parent(".rule_item").remove();
            }
            return false;
        })
        $("#group_rule_list").on("click", ".rule_del_level", function () {
            if ($(this).parent(".rule_item_level")) {
                $(this).parent(".rule_item_level").remove();
            }
            return false;
        })
        $("#btn1_cancel").on("click", function () {
            window.location.href = '/getAllActivity';
        });
        $("#btn2_cancel").on("click", function () {
            window.location.href = '/getAllActivity';
        });
        $("#btn3_cancel").on("click", function () {
            window.location.href = '/getAllActivity';
        });
        $("#btn4_cancel").on("click", function () {
            window.location.href = '/getAllActivity';
        });
        $("#btn5_cancel").on("click", function () {
            window.location.href = '/getAllActivity';
        });
        $("#btn6_cancel").on("click", function () {
            window.location.href = '/getAllActivity';
        });
        function hideImg(img_position) {
            $(".img_position").css("display", "block");
        }
    })
    
</script>
</body>
</html>